package com.ihrm.system.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @auther chongxiongwei
 * @create 2020-06-11-11:02
 */
@ApiOperation("人脸登录")
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Value("${swagger.enabled}")
    private boolean swaggerEnabled;

    // 配置SwaggerAPI文档信息
    private ApiInfo apiInfo() {
        // 作者信息
        Contact contact = new Contact("祥云天地", "http://www.yunworld.com.cn", "联系人邮箱");
        return new ApiInfo(
                "Saas-ihrm 系统服务接口", // 标题
                "对云文档的Graph接口进行封装，方便Client端直接调用，省去用户登录及Token的维护【方便VB直接调用】", // 描述
                "v1.0", // 版本
                "http://terms.service.url/组织链接", // 组织链接
                contact, // 联系人信息
                "Apach 2.0 许可", // 许可
                "许可链接", // 许可连接
                new ArrayList<>()// 扩展
        );
    }

    @Bean //配置docket以配置Swagger具体参数
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(swaggerEnabled)
                .groupName("system")
                .select()
                // RequestHandlerSelectors 配置要扫描接口的方式
                .apis(RequestHandlerSelectors.basePackage("com.ihrm.system.controller"))
                // 扫描路径路径
                .paths(PathSelectors.ant("/**"))
//                .paths(PathSelectors.ant("/graph/user/**"))
                .build();
    }

}
